package com.example.springbootjpasqllogdemo.common.config;

import org.modelmapper.ModelMapper;
import org.modelmapper.convention.MatchingStrategies;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 模型映射配置类
 *
 * @author Lv
 * @date 2022/10/3
 */
@Configuration
public class ModelMapperConfig {
    /**
     * 对象解析器
     */
    @Bean
    public ModelMapper modelMapper() {
        ModelMapper modelMapper = new ModelMapper();
        modelMapper.getConfiguration().setFullTypeMatchingRequired(true);
        modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
        modelMapper.addConverter(new InstantLongConverter());
        modelMapper.addConverter(new StringUUIDConverter());
        return modelMapper;
    }
}
